package PTA.Mianxiangduixiang.ex02;

import java.util.Scanner;

class Person{
    private String name;
    private boolean gender;
    private int age;
    private int id;
    Person(String name,int age,boolean gender){
        this.name = name;
        this.gender = gender;
        this.age = age;
    }
    Person(){
        System.out.println("This is constructor");
    }
static{
    System.out.println("This is static initialization block");

}
    {

    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public boolean isGender() {
        return gender;
    }

    public void setGender(boolean gender) {
        this.gender = gender;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    @Override
    public String toString() {
        return "Person[" +
                "name='" + name + '\'' +
                ", gender=" + gender +
                ", age=" + age +
                ", id=" + id +
                ']';
    }
}
public class ex02 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Person[] arr = new Person[n];
        //然后从控制台分别读取n行的name, gender, age, 并调用有参构造函数Person(name, age, gender)新建对象 。

        for(int i=0;i<n;i++){
            String name = sc.nextLine();
            int age = sc.nextInt();
            boolean gender = sc.nextBoolean();
           arr[i] = new Person(name,age,gender);
        }
        //将创建好的n个对象逆序输出(即输出toString()方法)。
      for(int i=arr.length-1;i>=0;i--){
          arr[i].toString();
      }
      //使用无参构造函数新建一个Person对象，然后直接打印该对象。
      Person p = new Person();
p.toString();
    }
}
